package com.zhu.exercise.array;

import org.junit.Test;

import java.util.Arrays;

public class MoveZeroes {

    public void moveZeroes(int[] nums) {
        int left = 0,right = 0;
        while(right<nums.length){
            if(nums[right]!=0){
                int tmp = nums[left];
                nums[left]= nums[right];
                nums[right]=tmp;
                left++;
            }
            right++;
        }

    }

    @Test
    public void run(){
        int[] array = {0,1,0,3,12};

         moveZeroes(array);

        Arrays.stream(array).forEach(e->System.out.println(e+","));

    }
}
